package com.infore.airsupervise.other;

import android.os.Looper;
import android.os.Message;

import com.infore.airsupervise.bean.ProgressBean;

/**
 * 文件下载handler
 * Created by xiaotao on 2017/7/15.
 */

public  abstract class DownLoaderProgressHanlder extends ProgressHandler {
    private static final int DOWNLOAD_PROGRESS = 1;
    protected ResponseHandler mHandler = new ResponseHandler(this, Looper.getMainLooper());



    @Override
    public void sendMessage(ProgressBean progressBean) {
        mHandler.obtainMessage(DOWNLOAD_PROGRESS,progressBean).sendToTarget();
    }

    @Override
    protected void handleMessage(Message message) {
        switch (message.what){
            case DOWNLOAD_PROGRESS:
                ProgressBean progressBean = (ProgressBean)message.obj;
                onProgress(progressBean.getBytesRead(),progressBean.getContentLength(),progressBean.isDone());
        }
    }

    }



